package lcr;

public class Test0070 {
}

class Solution0070_1 {
    public int singleNonDuplicate(int[] nums) {
        int length = nums.length, left = 0, right = length - 1;

        while (left < right){
            int mid = (left + right) >> 1;
            int num = nums[mid];

            if (mid<length-1&&num == nums[mid + 1]){
                if (mid % 2 == 0) left = mid+1;
                else right = mid-1;
            } else if (mid > 0&& num == nums[mid - 1]) {
                if (mid % 2 == 0) right = mid-1;
                else left = mid+1;
            }else return num;
        }

        return nums[left];
    }
}
